﻿<%namespace YouHP.Model%>
<%namespace YouHP.Utility%>
<%template _header%>

<div class="layout-cols2">
<%template _memmenu%>
	<div class="pannelcontent">

		<div class="pcontent">
		<div class="panneldetail">
	     <%template _memrecordermenu%>
	     	
			<div class="pannelbody">
	    <%csharp%>if( IsPost){ <%/csharp%>
	    
	    <%template _MsgBox%>
	    
	    <%csharp%> } else { <%/csharp%>
	    
	    <div class="box">
	        <div class="caption">
	            体重信息添加
	        </div>
	        <div class="content">
	               <table class="table-box">
	                <tbody>
	                    
	                <tr>
	                    <td class="table-box-left">时间</td>
	                    <td class="table-box-right">
	                        <input id="odate" type="text" name="odate" class="inputstyle" 
	                            readonly="true" value="{DateTime.Now.ToString("yyyy-MM-dd")}"
	                            onclick="WdatePicker({ isShowClear:false})"
	                         /></td>
	                    <td></td>
	                </tr>
	                <tr>
	                    <td class="table-box-left">体重</td>
	                    <td class="table-box-right">
	                        <input type="text" name="wvalue" id="wvalue"
	                                class="inputstyle" size="8"/> &nbsp; {WeightData.MeasurementUnits}
	                    </td>
	                    <td></td>
	                </tr>
	                
	                <%csharp%>if( Height<=0){ <%/csharp%>
	                <input type="hidden" name="hasHeight" value="1" />
	                <tr>
	                    <td class="table-box-left">身高</td>
	                    <td class="table-box-right">
	                        <input type="text" name="stature"  
	                                class="inputstyle" size="8" /> &nbsp; {WeightData.HeightUnits}
	                        &nbsp;&nbsp; 注：为计算体重指数，请填写正确的身高信息
	                    </td>
	                    <td></td>
	                </tr>
	                <%csharp%>}else {<%/csharp%>
	                <input type="hidden" name="hasHeight" value="0" />
	                <%csharp%>}<%/csharp%>	                
	                <tr>
	                    <td class="table-box-left"></td>
	                    <td class="table-box-right">
	                        <input class="buttonstyle" type="button" value="确定" onclick="javascript:OnOk()" />
	                        &nbsp;&nbsp;<input class="buttonstyle" type="reset" value="重置" />
	                    </td>
	                    <td></td>
	                </tr>
	                </tbody>
	                </table>
	        </div>
	    </div>
	    
	    <%csharp%> } <%/csharp%>
	    
	</div>
	</div>
	</div>
	</div>
	
</div>

<%template _footer%>

<script language="javascript">
function OnOk()
{
    function OnSucc(xmlDoc)
    {
        alert("添加成功");
        location.href = "Index.aspx" ;
    }
    
    function OnFail(xmlDoc)
    {
        var result = xmlDoc.getElementsByTagName("result")[0];
        var iCode = result.getAttribute("code");
        var sMsg = result.getAttribute("msg");
        if( iCode == -200 )
        {
            if( window.confirm(sMsg+",你确定需要覆盖该天的数据吗？") ) 
            {
                var surl="/pages/xml/historyweightadd.aspx?odate="+date+"&wvalue="+weight+"&hasheight="+hasHeight+"&height="+height+"&type=1";
                getResultXml(surl,OnSucc,OnFail,OnFail);
            }
        }
        else
        {
            alert(sMsg);
        }
        
    }
    
    var date= _$("odate").value;
    var weight=_$("wvalue").value;
    var hasHeight=_$("hasHeight").value;
    
    var height = 0;
    if(hasHeight > 0)
    {
        height = _$("stature").value;
    }
    
    var surl="/pages/xml/historyweightadd.aspx?odate="+date+"&wvalue="+weight+"&hasheight="+hasHeight+"&height="+height;
    getResultXml(surl,OnSucc,OnFail,OnFail);
}
</script>